#include <stdio.h>
#include <stdarg.h>

#include "font.h"

extern unsigned char *vBuffer;

const unsigned char	FONT6[] = {
//	 80,  77,  66,  80,  20,   6,   0,   0,   1,   0, 128,   0,  96,   0, 223, 119,
//	  0,   6,   0,   0,
	  0,  64, 192,  64,  64, 128,  96,  64,  64, 128,   0,   0,
	  0,   0,   0,   0,   0,  64, 192, 224,  96,  32,  96,  64, 128,  64, 160,  64,
	  0,   0,   0,  32,   0,  64,   0,  64,  64,  64,  64,   0, 128,  64,  64, 224,
	  0, 224,   0,  64,   0,   0,   0, 224, 192, 128, 224,   0, 128,  64, 160,  64,
	  0,   0,   0, 128,   0,  64,   0,  64,  64,  32, 224,   0,  64, 128,   0,   0,
	 64,   0,  64,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0, 224,  64, 224, 224,  32, 224, 224, 224, 224, 224,   0,   0,
	 32,   0, 128, 192, 160, 192,  32,  32,  96, 128, 128,  32, 160, 160,  64,  64,
	 64, 224,  64,  32, 160,  64, 224, 224, 160, 224, 224,  64, 224, 224,   0,   0,
	128,   0,  32,  64, 160,  64, 128,  32, 224,  32, 160,  64, 160,  32,  64,  64,
	 64, 224,  64,   0, 224,  64, 224, 224,  32, 224, 224,  64, 224, 224,   0,  64,
	 32,   0, 128,  64,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,  64,  64, 192,  64, 192, 224, 224,  96, 160,  64,  32, 160,
	128, 224, 192,  64, 160, 160, 160, 160, 160, 128, 128, 128, 160,  64,  32, 160,
	128, 224, 160, 160, 224, 224, 192, 128, 160, 224, 224, 160, 224,  64,  32, 192,
	128, 224, 160, 160, 224, 160, 160, 160, 160, 128, 128, 160, 160,  64, 160, 160,
	128, 160, 160, 160,  64, 160, 192,  64, 192, 224, 128,  96, 160,  64, 224, 160,
	224, 160, 160,  64,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0, 192,  64, 192,  96, 224, 160, 160, 160, 160, 160, 224, 192,
	160, 192,  64,   0, 160, 160, 160, 128,  64, 160, 160, 160, 160, 160,  32, 128,
	 64,  64, 160,   0, 192, 160, 192,  64,  64, 160, 160, 224,  64, 224,  64, 128,
	224,  64,   0,   0, 128, 224, 160,  32,  64, 160,  64, 224, 160,  64, 128, 128,
	224,  64,   0,   0, 128,  96, 160, 192,  64,  64,  64, 224, 160,  64, 224, 192,
	 64, 192,   0, 224,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0, 128,   0, 128,   0,  32,   0,  32,   0, 128,  64,  64, 128,
	 64,   0,   0,   0,  64,   0, 128,   0,  32,   0,  64,   0, 128,   0,   0, 128,
	 64,   0,   0,   0,   0,  96, 192,  96,  96,  64, 224, 224, 192,  64,  64, 160,
	 64, 224, 192, 224,   0, 160, 160, 128, 160, 160,  64, 224, 160,  64,  64, 192,
	 64, 224, 160, 160,   0,  96, 192,  96,  96, 192,  64,  32, 160,  64,  64, 160,
	 64, 160, 160, 224,   0,   0,   0,   0,   0,  96,   0, 192,   0,   0, 192,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  96,
	 64, 192, 224,   0,   0,   0,   0,   0,  64,   0,   0,   0,   0,   0,   0,  64,
	 64,  64,   0,   0, 192,  96, 224,  96, 224, 160, 160, 160, 160, 160, 224, 128,
	 64,  32,   0,  64, 160, 160, 128,  64,  64, 160, 160, 224,  64, 224,  64,  64,
	 64,  64,   0,   0, 192,  96, 128, 192,  64, 224,  64, 224, 160,  32, 224,  96,
	 64, 192,   0,   0, 128,  32,   0,   0,   0,   0,   0,   0,   0, 192,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0
};

const unsigned char	FONT16[] = {
//	 80,  77,  66,  80,  20,   6,   0,   0,   1,   0, 128,   0,  96,   0, 223, 119,
//	  0,   6,   0,   0,
	  0,   0,  54,   0,  24,   0,   0,  56,  24, 192,   0,   0,
	  0,   0,   0,   0,   0,  24,  54, 102,  60, 115,  56,  56,  48,  96,   0,   0,
	  0,   0,   0,   3,   0,  24, 108, 102, 126, 219, 108,  24,  96,  48,   0,   0,
	  0,   0,   0,   3,   0,  24,   0, 102, 219, 222, 108,  48,  96,  48,  24,   0,
	  0,   0,   0,   6,   0,  24,   0, 102, 219, 222, 108,   0, 192,  24, 219,  24,
	  0,   0,   0,   6,   0,  24,   0, 255, 120, 124, 108,   0, 192,  24, 126,  24,
	  0,   0,   0,  12,   0,  24,   0, 102,  56,  12,  56,   0, 192,  24,  60,  24,
	  0,   0,   0,  12,   0,  24,   0, 102,  28,  24,  48,   0, 192,  24,  24, 255,
	  0, 126,   0,  24,   0,  24,   0, 102,  30,  48, 126,   0, 192,  24,  60,  24,
	  0,   0,   0,  48,   0,  24,   0, 102,  27,  62, 222,   0, 192,  24, 126,  24,
	  0,   0,   0,  48,   0,   0,   0, 255, 219, 123, 204,   0, 192,  24, 219,  24,
	  0,   0,   0,  96,   0,   0,   0, 102, 219, 123, 204,   0,  96,  48,  24,   0,
	 28,   0,   0,  96,   0,  24,   0, 102, 126, 219, 222,   0,  96,  48,   0,   0,
	 28,   0,  28, 192,   0,  24,   0, 102,  60, 206, 115,   0,  48,  96,   0,   0,
	 12,   0,  28, 192,   0,   0,   0, 102,  24,   0,   0,   0,  24, 192,   0,   0,
	 24,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,  28,  12,  28,  28,   6, 127,  28, 127,  28,  28,   0,   0,
	  0,   0,   0,  24,  54,  60,  54,  54,   6,  96,  54,   3,  54,  54,   0,   0,
	  3,   0,  96,  60,  99,  12,  99,  99,  14,  96,  99,   3,  99,  99,   0,   0,
	  6,   0,  48, 102,  99,  12,  99,  99,  14,  96,  99,   6,  99,  99,   0,   0,
	 12,   0,  24, 102,  99,  12,   3,   3,  30, 124,  96,   6,  99,  99,  28,  28,
	 24, 126,  12,   6,  99,  12,   6,   6,  30, 118, 124,  12,  54,  99,  28,  28,
	 48,   0,   6,   6,  99,  12,   6,  28,  54,  99, 118,  12,  28,  55,   0,   0,
	 96,   0,   3,  12,  99,  12,  12,   6,  54,   3,  99,  12,  54,  31,   0,   0,
	 48,   0,   6,  24,  99,  12,  24,   3, 102,   3,  99,  24,  99,   3,   0,   0,
	 24, 126,  12,  24,  99,  12,  24,  99, 127,   3,  99,  24,  99,  99,   0,   0,
	 12,   0,  24,   0,  99,  12,  48,  99,   6,  99,  99,  24,  99,  99,  28,  28,
	  6,   0,  48,   0,  54,  12,  96,  54,   6,  54,  54,  24,  54,  54,  28,  28,
	  3,   0,  96,  24,  28,  12, 127,  28,   6,  28,  28,  24,  28,  28,   0,  12,
	  0,   0,   0,  24,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  24,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,  60,  24, 252,  60, 252, 255, 255,  60, 195,  60,   3, 195,
	192, 195, 195,  60, 102,  24, 198, 102, 198, 192, 192, 102, 195,  24,   3, 198,
	192, 195, 227, 102, 195,  60, 195, 195, 195, 192, 192, 195, 195,  24,   3, 198,
	192, 195, 227, 195, 223,  60, 195, 195, 195, 192, 192, 195, 195,  24,   3, 204,
	192, 231, 243, 195, 255,  60, 195, 192, 195, 192, 192, 192, 195,  24,   3, 216,
	192, 231, 243, 195, 255,  60, 198, 192, 195, 192, 192, 192, 195,  24,   3, 216,
	192, 231, 219, 195, 255, 102, 252, 192, 195, 254, 254, 192, 255,  24,   3, 240,
	192, 255, 219, 195, 255, 102, 198, 192, 195, 192, 192, 207, 195,  24,   3, 248,
	192, 255, 207, 195, 255, 102, 195, 192, 195, 192, 192, 195, 195,  24,   3, 204,
	192, 255, 207, 195, 222, 126, 195, 195, 195, 192, 192, 195, 195,  24,  99, 204,
	192, 255, 199, 195, 192, 195, 195, 195, 195, 192, 192, 195, 195,  24,  99, 198,
	192, 219, 199, 195,  99, 195, 198, 102, 198, 192, 192, 103, 195,  24,  54, 195,
	192, 219, 195, 102,  62, 195, 252,  60, 252, 255, 192,  63, 195,  60,  28, 195,
	255, 219, 195,  60,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 126,
	  0, 126,  24,   0, 252,  60, 252,  60, 255, 195, 195, 219, 195, 195, 255,  96,
	195,   6,  60,   0, 198, 102, 198, 102,  24, 195, 195, 219, 195, 195,   3,  96,
	195,   6, 102,   0, 195, 195, 195, 195,  24, 195, 195, 219, 102, 102,   6,  96,
	102,   6,   0,   0, 195, 195, 195, 195,  24, 195, 102, 219, 102, 102,   6,  96,
	102,   6,   0,   0, 195, 195, 195, 192,  24, 195, 102, 219,  60,  60,  12,  96,
	 60,   6,   0,   0, 198, 195, 198, 112,  24, 195, 102, 255,  60,  60,  12,  96,
	 60,   6,   0,   0, 252, 195, 252,  28,  24, 195, 102, 255,  24,  24,  24,  96,
	126,   6,   0,   0, 192, 195, 204,   6,  24, 195,  60, 255,  60,  24,  48,  96,
	 24,   6,   0,   0, 192, 195, 204,   3,  24, 195,  60, 102,  60,  24,  48,  96,
	 24,   6,   0,   0, 192, 219, 198, 195,  24, 195,  60, 102, 102,  24,  96,  96,
	126,   6,   0,   0, 192, 207, 198, 195,  24, 195,  24, 102, 102,  24,  96,  96,
	 24,   6,   0,   0, 192, 102, 195, 102,  24, 102,  24, 102, 195,  24, 192,  96,
	 24,   6,   0,   0, 192,  63, 195,  60,  24,  60,  24, 102, 195,  24, 255,  96,
	 24,   6,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 126,
	  0, 126,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0, 255,  48,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,  24,   0, 192,   0,   3,   0,  14,   0, 192,   0,   0, 192,
	 24,   0,   0,   0,  12,   0, 192,   0,   3,   0,  24,   0, 192,  24,  24, 192,
	 24,   0,   0,   0,   0,   0, 192,   0,   3,   0,  24,   0, 192,  24,  24, 192,
	 24,   0,   0,   0,   0,   0, 192,   0,   3,   0,  24,   0, 192,   0,   0, 192,
	 24,   0,   0,   0,   0,   0, 192,   0,   3,   0,  24,   0, 192,   0,   0, 192,
	 24,   0,   0,   0,   0, 124, 252,  62,  63,  60, 126,  63, 252,  24,  24, 198,
	 24, 254, 252,  60,   0, 198, 230,  99, 103, 102,  24, 102, 230,  24,  24, 204,
	 24, 219, 230, 102,   0,   6, 195, 192, 195, 195,  24, 102, 195,  24,  24, 216,
	 24, 219, 195, 195,   0,  62, 195, 192, 195, 255,  24,  60, 195,  24,  24, 240,
	 24, 219, 195, 195,   0, 102, 195, 192, 195, 192,  24,  96, 195,  24,  24, 248,
	 24, 219, 195, 195,   0, 198, 195, 192, 195, 192,  24, 126, 195,  24,  24, 204,
	 24, 219, 195, 195,   0, 206, 230,  99, 103,  99,  24, 195, 195,  24,  24, 198,
	 24, 219, 195, 102,   0, 127, 252,  62,  63,  62,  24, 195, 195,  24,  24, 195,
	 24, 219, 195,  60,   0,   0,   0,   0,   0,   0,   0, 126,   0,   0, 112,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  30,
	 24,  60,  59,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  24,
	 24,  12, 110,   0,   0,   0,   0,   0,  24,   0,   0,   0,   0,   0,   0,  24,
	 24,  12,   0,   0,   0,   0,   0,   0,  24,   0,   0,   0,   0,   0,   0,  24,
	 24,  12,   0,   0,   0,   0,   0,   0,  24,   0,   0,   0,   0,   0,   0,  24,
	 24,  12,   0,   0,   0,   0,   0,   0,  24,   0,   0,   0,   0,   0,   0,  24,
	 24,  12,   0,   0, 252,  63, 126, 126, 126, 195, 195, 219, 195, 195, 255,  24,
	 24,  12,   0,   0, 230, 103, 112, 195,  24, 195, 195, 219, 102, 195,   6,  48,
	 24,   6,   0,   0, 195, 195,  96, 192,  24, 195, 102, 219,  60,  98,  12,  24,
	 24,  12,   0,   0, 195, 195,  96, 112,  24, 195, 102, 255,  24, 102,  24,  24,
	 24,  12,   0,   0, 195, 195,  96,  30,  24, 195,  60, 255,  24,  52,  48,  24,
	 24,  12,   0,   0, 230, 103,  96,   3,  24, 195,  60, 102,  60,  60,  96,  24,
	 24,  12,   0,   0, 252,  63,  96, 195,  24, 103,  24, 102, 102,  24, 192,  24,
	 24,  12,   0,   0, 192,   3,  96, 126,  14,  63,  24, 102, 195,  48, 255,  24,
	 24,  12,   0,   0, 192,   3,   0,   0,   0,   0,   0,   0,   0, 224,   0,  30,
	 24,  60,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	 24,   0,   0,   0
};

const unsigned char *font_adr = FONT6;
int font_posX = 0, font_posY = 0, font_width = 4, font_height = 6;
unsigned char font_fgcolor = 3, font_bgcolor = 0, font_bgclear = 0;


void fnt_printf(const char *fmt, ...)
{
	unsigned char *adr = vBuffer + font_posX + font_posY * 128;
	char *pC;
	char c[1024];
	va_list argp;

	va_start(argp, fmt);
	vsprintf(c, fmt, argp);
	va_end(argp);

	pC = c;
	while(*pC) {
		int i, x, y;
		const unsigned char *sAdr;
		if(*pC >= 0x20 && *pC < 0x80) {
			i = *pC - 0x20;
		} else {
			i = 0;
		}
		sAdr = font_adr + (i & 15) + (i >> 4) * 16 * 16;
		for(y = 0; y < font_height; y ++) {
			unsigned char c = *sAdr;
			for(x = 0; x < font_width; x ++) {
				if(c & 0x80) {
					*adr = font_fgcolor;
				} else if(font_bgclear == 0) {
					*adr = font_bgcolor;
				}
				adr ++;
				c <<= 1;
			}
			adr += 128 - font_width;
			sAdr += 16;
		}
		adr -= 128 * font_height - font_width;
		pC ++;
	}
}

void fnt_pos(int x, int y)
{
	font_posX = x;
	font_posY = y;
}

void fnt_type(int type)
{
	const int width[] = {5, 8, 4};
	const int height[] = {10, 16, 6};
	const unsigned char* adr[] ={FONT6, FONT16, FONT6};

	type &= 3;
	font_width = width[type];
	font_height = height[type];
	font_adr = adr[type];
}

void fnt_color(int color)
{
	font_fgcolor = (unsigned char)color;
}

void fnt_bgcolor(int color)
{
	if(color >= 0) {
		font_bgcolor = (unsigned char)color;
		font_bgclear = 0;
	} else {
		font_bgclear = 1;
	}
}
